package com.link.base.base.appmenuurls.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.link.base.base.appduty.model.AppMenu;
import com.link.core.basic.annotations.JsonParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.base.appmenuurls.model.AppMenuUrls;
import com.link.base.base.appmenuurls.service.AppMenuUrlsService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * app菜单下页面路径
 *
 * @author 秦学刚
 * @date 2020-07-07 16:19:35
 */
@Controller
@RequestMapping("/link/appMenuUrls")
public class AppMenuUrlsController extends BasicController<AppMenuUrls> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private AppMenuUrlsService appMenuUrlsService;

    @Override
    public BasicService<AppMenuUrls> getBasicService() throws Exception {
        return appMenuUrlsService;
    }


    /**
     * APP 添加菜单下的路径到中间表
     *
     * @author qinxg
     * @date 2020/7/7
     * @param entity
     * @param session
     * @param request
     * @param response
     * @return
     **/
    @RequestMapping({"/addAppPageUrlAll"})
    @ResponseBody
    public Map<String, Object> addAppPageUrlAll(@JsonParam AppMenu entity, HttpSession session,
                                                HttpServletRequest request, HttpServletResponse response) {
        HashMap result = new HashMap(4);
        try {
//            if (entity == null || entity.getUrlPath() == null || entity.getId() == null) {
//                throw new Exception("缺少菜单信息，请检查数据");
//            }
            appMenuUrlsService.addAppPageUrlAll();
            result.put("success", true);
            result.put("code", "200");
        } catch (Exception var8) {
            result.put("success", false);
            result.put("result", var8.getMessage());
            result.put("code", "400");
        }
        return result;
    }
}